﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace OpGen.Compiler
{
    /// <summary>
    /// Stellt ein Feld-Element dar
    /// </summary>
    [Serializable]
    public class OpGenField : OpGenElement
    {
        /// <summary>
        /// Erzeigt eine neue Instanz der FieldElement-Klasse
        /// </summary>
        /// <param name="Element"></param>
        public OpGenField(OpGenClass Element) : base(Element, ElementTypeEnum.Field)
        {

        }

        /// <summary>
        /// Erzeigt eine neue Instanz der FieldElement-Klasse
        /// </summary>
        /// <param name="Element"></param>
        public OpGenField(OpGenMessage Element) : base(Element, ElementTypeEnum.Field)
        {

        }

        public string DefaultValue { get; set; }

        public override string ToString()
        {
            var SB = new StringBuilder();

            SB.Append(Modifier.ToString());
            SB.Append(" ");

            if (Type.Type == TypeEnum.REFERENCE)
                SB.Append(Type.ReferenceElement.Elementname);
            else
                SB.Append(Type.Type.ToString());
            
            SB.Append(" ");

            SB.Append(Elementname);
            SB.Append(" ");

            if (Type.IsList)
                SB.Append("\n LIST");

            if (DefaultValue != null)
                SB.Append("\n DEFAULT : " + DefaultValue);

            return SB.ToString();
        }
    }
}
